//
//  MatePeopleListTableViewCell.m
//  TQY
//
//  Created by 甘世清 on 2024/10/3.
//

#import "MatePeopleListTableViewCell.h"

@implementation MatePeopleListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    [self.contentView addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(50);
            make.left.equalTo(self.contentView).offset(12);
        make.centerY.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerView.mas_right).offset(8);
        make.centerY.equalTo(self.headerView);
    }];
    [self.contentView addSubview:self.deletedBtn];
    [self.deletedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-12);
        make.width.mas_equalTo(90);
        make.height.mas_equalTo(30);
        make.centerY.equalTo(self.headerView);
    }];
    
    
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQColorF5F5F5;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(12);
            make.bottom.right.equalTo(self.contentView);
            make.height.mas_equalTo(1);
    }];
}
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    NSString * header = [NSString stringWithFormat:@"%@",[dic objectForKey:@"portrait"]];
    [self.headerView.headerImage sd_setImageWithURL:SQURLImage(header) placeholderImage:SQGetImage(@"1")];
    self.nameLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"name"]];
  
}

-(void)SQ_headerViewButtonClick{
    PeopleDetailViewController * vc = [[PeopleDetailViewController alloc]init];
    vc.uid = [self.dic objectForKey:@"uid"];
    [[Manager SQ_getCurrentViewController].navigationController pushViewController:vc animated:YES];
}
 
 
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor = UIColor.blackColor;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}

- (HeaderView *)headerView{
    if (!_headerView) {
        _headerView = [[HeaderView alloc]init];
        _headerView.headerImage.contentMode = UIViewContentModeScaleAspectFill;
        _headerView.clipsToBounds = YES;
        [_headerView.btn addTarget:self action:@selector(SQ_headerViewButtonClick) forControlEvents:UIControlEventTouchUpInside];
        _headerView.layer.cornerRadius = 25;
        _headerView.layer.masksToBounds = YES;
    }
    return _headerView;
}
 
 
- (SQCustomButton *)deletedBtn{
    if (!_deletedBtn) {
        _deletedBtn = [[SQCustomButton alloc]initType:SQCustomButtonLeftImageType imageSize:CGSizeMake(18, 18) midmargin:6];
        _deletedBtn.image = SQGetImage(@"shanchu");
        _deletedBtn.text = SQNSLocalString(@"请出");
        _deletedBtn.font = FONT_REGULAR(14);
        _deletedBtn.backgroundColor = SQHexColor(@"#999999", 0.5);
        _deletedBtn.textColor = UIColor.whiteColor;
        _deletedBtn.layer.cornerRadius = 15;
        _deletedBtn.layer.masksToBounds = YES;
        _deletedBtn.hidden = YES;
    }
    return _deletedBtn;
}
@end
